﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using AutoFacUtils;
using CashFlow.Web.Filters;
using CashFlow.Web.Common;
using CashFlow.Web.Areas.ShopManage.Models.Appointment;
using CashFlow.Web.Areas.ShopManage.Validator.Appointment;
using CashFlow.Web.Service;
using IAppointmentService2 = CashFlow.Web.Areas.ShopManage.Service.IAppointmentService;

namespace CashFlow.Web.Areas.ShopManage.Controllers
{
    public class AppointmentController : Controller
    {
        private IUserService GetUserService() { return AutoFacHelper.Get<IUserService>(); }
        private IAppointmentService2 GetAppointmentService2() { return AutoFacHelper.Get<IAppointmentService2>(); }

        // GET: ShopManage/Appointment
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        [ValidatorFilter(typeof(QueryAppointmentModelValidator))]
        public ActionResult QueryByWhere(QueryAppointmentModel model)
        {
            var userService = GetUserService();
            var si = userService.GetLoginShopInfo();
            var appointmentService2 = GetAppointmentService2();
            var ls = appointmentService2.QueryByWhere(
                          si.ShopManagerUserId
                          , model.Date
                          , model.Name
                     );
            return MyCommonTool.CreateOperationResult(true, "", ls);
        }
    }
}